#!/bin/bash

ROOT_DIR=$(dirname ${0})/..
cd ${ROOT_DIR}
ROOT_DIR=$(pwd)
RELEASE_DIR=/work/release/iecg/server/

echo ${ROOT_DIR}

update_code()
{
    echo "****************sync code*************************"
    cd ${ROOT_DIR}
    git pull origin master
}

build_project()
{
    
    echo "****************build project*************************"
    cd ${ROOT_DIR}
    mvn clean install -Dmaven.test.skip=true
}

copy_to_release()
{
    echo "****************release file*************************"
    cp pigx-register/target/pigx-register.jar ${RELEASE_DIR}    
    cp pigx-gateway/target/pigx-gateway.jar ${RELEASE_DIR}    
    cp pigx-auth/target/pigx-auth.jar ${RELEASE_DIR}    
    cp pigx-upms/pigx-upms-biz/target/pigx-upms-biz.jar ${RELEASE_DIR}    
}

exec_script()
{
    sh /work/release/iecg/server/restart.sh pigx-register &
    sleep 10s
    sh /work/release/iecg/server/restart.sh pigx-gateway &
    sleep 10s
    sh /work/release/iecg/server/restart.sh pigx-auth &
    sleep 10s
    sh /work/release/iecg/server/restart.sh pigx-upms-biz &
}
####main####
#update_code
#build_project
#copy_to_release 

sh /work/release/iecg/server/restart.sh pigx-register &
sleep 10s
sh /work/release/iecg/server/restart.sh pigx-gateway &
sleep 10s
sh /work/release/iecg/server/restart.sh pigx-auth & 
sleep 10s
sh /work/release/iecg/server/restart.sh pigx-upms-biz &

